Accusoft.BarcodeXpress12.Net - Updated
Create a 1D Barcode
User Guide > How To > Create a Barcode > Create a 1D Barcode

Basic Steps to Create a 1D Barcode

  1. Set the value you want to create.
    Property  Description
    BarcodeType Gets and sets the type of barcode to create from the BarcodeType enumeration.
    BarcodeValue Gets and sets the value of the barcode to be created.
    BarcodeData Gets and sets the current barcode value as an array of bytes used only if non-ASCII text values are needed.

  1. Call either the Create method (to create an hDib) or the CreateBitmap method (to create a System.Drawing.Bitmap) from the BarcodeXpress.writer member. These methods will return an image with the desired barcode.
    Method Description
    Create The main method for creating barcodes.
    CreateBitmap Creates bitmap barcodes.
    There are many additional properties within the Writer class which may be used as needed in creating barcodes. See the class overview for more information.

C# - Basic steps for barcode writing 1D barcodes using Accusoft.BarcodeXpress.Net 
Copy Code
//create and unlock the BarcodeXpress component
BarcodeXpress bcx = new BarcodeXpress();
//  The SetSolutionName and SetSolutionKey methods must be called to distribute the runtime.
bcx.Licensing.SetSolutionName("YourSolutionName");
bcx.Licensing.SetSolutionKey(12345,12345,12345,12345);
//  The SetOEMLicenseKey method is required if Manually Reported Runtime Licensing is used.
bcx.Licensing.SetOEMLicenseKey("1.0.AStringForOEMLicensing");

//set the required writer properties
bcx.writer.BarcodeType = BarcodeType.Code39Barcode;
bcx.writer.BarcodeValue = "CODE39";

//call Create and get resulting image
imageXView1.Image = Accusoft.ImagXpressSdk.ImageX.FromHdib(imagXpress1, bcx.writer.Create());
// dispose of the barcode component
bcx.Dispose(); 

1D barcode values are generally 7 bit ASCII, except for Code 128, which permits the use of 8 bit data. If you are using values above 127, you must use the BarcodeDataAsByte property of the Result class instead of the BarcodeValue property, and your data must be encoded. Also, the reader and writer must both use the same character set.

For writing 1D barcode, Code 128, using encoded 8859-15
Copy Code
//set the required writer properties
System.Text.Encoding iso = System.Text.Encoding.GetEncoding("ISO-8859-15");
bcx.writer.BarcodeData = iso.GetBytes("€27.99");
The 1D writing sample provided with Barcode Xpress uses 8859-15 just to demonstrate this technique.

 

See Also